export default {
  namespaced: true,
  state: {
    showloginbtn: localStorage.getItem("token") ? false : true,
    user: JSON.parse(localStorage.getItem("user")) || "", //储存用户信息
    showLogin: false, //存储何时显示登录界面
  },
  getters: {
    // 获取用户信息
    getUser(state) {
      return state.user;
    },
    // 获取用户登录状态
    getShowlogin(state) {
      return state.showLogin;
    },
    getshowloginbtn(state) {
      return state.showloginbtn;
    },
  },
  mutations: {
    setUser(state, data) {
      state.user = data;
    },
    setshowLogin(state, data) {
      state.showLogin = data;
    },
    setshowloginbtn(state, data) {
      state.showloginbtn = data;
    },
  },
  actions: {
    setuser({ commit }, data) {
      commit("setUser", data);
    },
    setshowlogin({ commit }, data) {
      commit("setshowLogin", data);
    },
    setshowloginbtn({ commit }, data) {
      commit("setshowloginbtn", data);
    },
  },
};
